﻿@{

}
<!DOCTYPE html>
<html>
<head>
    <title>车辆列表</title>
    <link href="~/EasyUI/themes/icon.css" rel="stylesheet" />
    <link href="~/EasyUI/themes/default/easyui.css" rel="stylesheet" />
    <script type="text/javascript" src="~/Scripts/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="~/EasyUI/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="~/Scripts/jquery.validate.min.js"></script>

    <script src="~/Scripts/Showdatetime.js"></script>
    <script type="text/javascript" src="~/Scripts/jquery.msgProcess.js"></script>

    <script type="text/javascript">
        //$.fn.datebox.defaults.formatter = function (date) {
        //    var y = date.getFullYear();
        //    var m = date.getMonth() + 1;
        //    var d = date.getDate();
        //    return  y + '-' + m + '-' + d ;
        //}
        $(function () {
            //加载店铺
            $.ajax({
                type: "POST",
                url: "/admin/Shop/DataList",
                data: { page: 1, rows: 1000 },
                dataType: "json",
                success: function (data) {
                    // $('#shops').empty();   //清空shops里面的所有内容
                    var html = '';
                    $.each(data.rows, function (commentIndex, comment) {
                        html += '<option value="' + comment['ID'] + '"> ' + comment['ShopName'] + '</option>';
                    });
                    $('#shops').append(html);
                }
            });
 
            $("#btnserch").click(function () {
                $('#tbList').datagrid('load', {
                    Shopid: $('#shops').val(),
                    brandName: $('#brandName').val(),
                    speedAssembly: $('#speedAssembly').val(),
                    xingHao: $('#xingHao').val(),
                    sellState: $('#sellState').val(),
                    CloseBegin: $('#CloseBegin').val(),
                    CloseEnd: $('#CloseEnd').val(),
                });
            })
         
            $('#editWindow').window('close');

            $("#tbList").datagrid({
                width: 'auto',
                height: 'auto',
                queryParams: {
                    sellState:-1
                },
                fitColumns: true,
                striped: true,
                singleSelect: true,
                url: '/admin/car/CarList',
                //queryParams:{},
                loadMsg: '数据加载中请稍后……',
                pagination: true,//启用分页，默认每页10行
                rownumbers: false,//显示行号.
                pageSize: 10,//设置 页容量为 5
                pageList: [5, 10, 20],//设置 页容量下拉框
                columns: [[

                    { field: 'id', title: 'id', width: 30 },
                    { field: 'brandName', title: '品牌', width: 40 },
                    { field: 'xingHao', title: '型号', width: 100 },

                    {
                        field: 'firstImg', title: '首图', width: 200, formatter: function (value) {
                            if (value == "" || value == null) {
                                return "<img width='140' height='100' src='../../upImg/noimg2.jpg'>";
                            }
                            else {
                                return "<img width='200' height='140' src='../../" + value + "'>";
                            }

                        }
                    },
                    {
                        field: 'regdate', title: '上户日期', width: 80, formatter: function (value) {
                            if (value == null || value == "") {
                                return '';
                            }
                            var aa = eval('new ' + (value.replace(/\//g, '')));
                            return aa.format("yyyy-MM-dd");
                        }
                    },
                    { field: 'speedAssembly', title: '变速箱', width: 50 },
                    { field: 'showPrice', title: '显示价', width: 50 },
                    { field: 'sellPrice', title: '内部价', width: 50 },
                    {
                        field: 'sellState', title: '状态', width: 50, formatter: function (value) {
                            if (value==1) {
                                return "正常";
                            }
                            else if (value == 2) {
                                return "下架";
                            }
                            else if (value == 3) {
                                return "已卖";
                            }
                            else if (value == 0) {
                                return "已删除";
                            }
                            return '';
                        }
                    },
                    {
                        field: 'CloseTime', title: '成交时间', width: 80, formatter: function (value) {
                            if (value == null || value == "") {
                                return '';
                            }
                            var aa = eval('new ' + (value.replace(/\//g, '')));
                            return aa.format("yyyy-MM-dd");
                        }
                    },
                    { field: 'closePrice', title: '成交价', width: 50 },
                    { field: 'ShopName', title: '店铺', width: 70 },


                ]],
                toolbar: [ '-', {
                    iconCls: 'icon-more',
                    text: "详情",
                    handler: detailRow
                }],
                onSelect: function (rowI, rowD) {
                    selectedRowIndex = rowI;//将选中行的下标 设置给全局变量
                },
                onDblClickRow: function () {
                    editRow();
                }
            });
        })

        //选中行的下标
        var selectedRowIndex = -1;
        var url = '@ViewBag.url';

        //编辑按钮方法
        function detailRow() {
          
            //获取选中行里的数据！
            var rowData = $("#tbList").datagrid("getSelected");
            if (rowData) {
              //  window.location = url+"index.html#/pages/carinfo/carDetail?carid=" + rowData.id;
                window.open(url + "index.html#/pages/carinfo/carDetail?carid=" + rowData.id);
            }
        }

        //编辑按钮方法
        function editRow() {
            //获取选中行里的数据！
            var rowData = $("#tbList").datagrid("getSelected");
            if (rowData) {
                window.location = "/admin/car/Editcar?id=" + rowData.id;

            }
        }
         
        //删除方法
        function removeRow() {
            ////获取选中行里的数据！
            //var rowData = $("#tbList").datagrid("getSelected");
            //if (rowData) {
            //    $.post("/admin/car/Dlecar", "id=" + rowData.id, function (jsonObj) {
            //        $.procAjaxData(jsonObj, function () {
            //            $("#tbList").datagrid("reload");//删除成功后 刷新页面
            //        });
            //    }, "JSON");
            //}
        }



    </script>
</head>
<body>
    <div style=" margin:15px 0px 20px 50px">
        品牌：<input id="brandName" type="text" style="width:70px" /> &nbsp; &nbsp;
        型号：<input id="xingHao" type="text" style="width:100px" /> &nbsp; &nbsp;
        变速箱： <select id="speedAssembly">
            <option value=""> 请选择</option>
            <option value="手动">手动</option>
            <option value="自动">自动</option>
            <option value="双离合">双离合</option>
            <option value="CVT">CVT</option>
        </select>

        所属店铺：
        <select id="shops">
            <option value="0"> 请选择</option>
        </select>&nbsp; &nbsp;
        状态：
        <select id="sellState">
            <option value="-1" selected> 请选择</option>
            <option value="1" > 正常</option>
            <option value="2"> 下架</option>
            <option value="3"> 已卖</option>
            <option value="0" > 已删除</option>
        </select>
        &nbsp; &nbsp;
        卖出日期：
        <input id="CloseBegin" type="text" style="width:120px"  placeholder="月/日/年" class="easyui-datebox">-
        <input id="CloseEnd" type="text"  style="width:120px" placeholder="月/日/年" class="easyui-datebox">

        <input id="btnserch" type="button" value="搜索" />
    </div>

    <table id="tbList" style="width:auto;height:auto"></table>

    <div id="editWindow" class="easyui-window" title="My Window" style="width:900px;height:400px;"
         data-options="iconCls:'icon-save',modal:true">

    </div>
</body>
</html>
    